
import Ajax from '@/api/ajax.js'
import MockAjax from "@/api/mockAjax";
import user from "@/store/user";

 export const  reqCategoryList=()=>{
    return Ajax({
        url:'/product/getBaseCategoryList',
        method:'get'
    })
}
//mock的数据接口 banner floor
// /mock/banner   get
export const  reqBannerList=()=>{
     return MockAjax({
         url:'/banner',
         method:'get'
     })
}
export const  reqFloorList=()=>{
     return MockAjax({
         url:'/floor',
         method:'get'
     })
}
//搜索页面获取数据 /list  请求方式post
 export const reqSearchList=(searchParams)=>{
     return Ajax({
         url:'/list',
         method:'post',
         data:searchParams
     })
 }
//detail 详情页面 /api/item/{ skuId } 方式get
export const reqDetailInfo=(skuId)=>{
    return Ajax({
        url:`/item/${skuId}`,
        method:'get'
    })
}
// 添加到购物车  /api/cart/addToCart/{ skuId }/{ skuNum } post
export const reqAddOrUpdateShopCart=(skuId,skuNum)=>{
     return Ajax({
         url:`/cart/addToCart/${ skuId }/${ skuNum }`,
         method:'post'
     })
}
//购物车信息  /api/cart/cartList 请求方式get
export const reqShopCart=()=>{
     return Ajax({
         url:'/cart/cartList',
         method:'get'
     })
}
//切换商品选中 单个状态
// /api/cart/checkCart/{skuId}/{isChecked} get请求
export const  reqCartOneChecked=(skuId,isChecked)=>{
     return Ajax({
         url:`cart/checkCart/${skuId}/${isChecked}`,
         method:'get'
     })
}
//批量修改状态 /api/cart/batchCheckCart/{isChecked} post
// isChecked   1或者0                               params参数
// skuIds       要修改的购物车商品的id组成的数组      body参数
export const reqCartAllChecked=(isChecked,skuIds)=>{
     return Ajax({
         url:`/cart/batchCheckCart/${isChecked} `,
        method:'post',
         data:skuIds
     })
}
//删除单个商品 /api/cart/deleteCart/{skuId} delete
export const reqDeleteOneCart=(skuId)=>{
     return Ajax({
         url:`/cart/deleteCart/${skuId}`,
         method:'delete',
     })
}
//批量删除多个商品
// /api/cart/batchDeleteCart delete skuIds      要删除的购物车商品的id组成的数组      body参数
export const reqDeleteMoreCart=(skuIds)=>{
     return Ajax({
         url:'/cart/batchDeleteCart',
         method:'delete',
         data:skuIds
     })
}
// /api/user/passport/sendCode/{phone}// 获取验证码 // get

export const reqGetCode=(phone)=>{
     return Ajax({
         url:`/user/passport/sendCode/${phone}`,
         method:'get'
     })
}
//注册 /api/user/passport/register POST phone   password   code
export const reqUserRegister=(userInfo)=>{
     return Ajax({
         url:'/user/passport/register',
         method:'post',
         data:userInfo
     })
}
//登录  /api/user/passport/login post phone password
export const reqUserLogin=(userInfo)=>{
     return Ajax({
         url:'/user/passport/login',
         method:'post',
         data:userInfo
     })
}
//获取用户信息
// /api/user/passport/auth/getUserInfo  get
export const reqUserInfo=()=>{
     return Ajax({
         url:'/user/passport/auth/getUserInfo',
         method:'get'
     })
}
//退出登录 /api/user/passport/logout get
export  const reqUserLogout=()=>{
     return Ajax({
         url:'/user/passport/logout',
         method:'get'
     })
}
//trade信息
//api/order/auth/trade get
export const reqGetTrade=()=>{
     return Ajax({
         url:'/order/auth/trade',
         method:'get'
         }
     )
}
//获取用户地址信息/api/user/userAddress/auth/findUserAddressList get
export const reqUserAddressList=()=>{
     return Ajax({
         url:'/user/userAddress/auth/findUserAddressList',
         method:'get'
     })
}
///api/order/auth/submitOrder?tradeNo={tradeNo} post
export const reqSubmitOrder=(tradeNo,submitOrderParams)=>{
     return Ajax({
         url:`/order/auth/submitOrder?tradeNo=${tradeNo}`,
         method:'post',
         data:submitOrderParams
     })
}
///api/payment/weixin/createNative/{orderId}
export const reqPay=(orderId)=>{
     return Ajax({
         url:`/payment/weixin/createNative/${orderId}`,
         method:'get'
     })
}
//获取支付状态码
//api/payment/weixin/queryPayStatus/{orderId}
export const reqPayStatus=(orderId)=>{
     return Ajax({
         url:`/payment/weixin/queryPayStatus/${orderId}`,
         method:'get'
     })
}
// /api/order/auth/{page}/{limit}
export const reqPagination=(page,limit)=>{
     return Ajax({
         url:`/order/auth/${page}/${limit}`,
         method:'get'
     })
}
//测试接口是否可用
//reqCategoryList()
//reqSearchList({})